import 'package:flutter/material.dart';
import 'package:shopping_group/main/lz_hot_cakes/model/lz_hot_cakes_product_model.dart';
import 'package:shopping_group/modle/main/ui/details_page.dart';
import 'package:shopping_group/res/dimens.dart';
import 'package:shopping_group/utils/route_util.dart';

class LzHotCakesProductWidget extends StatefulWidget {
  //商品Model
  final LzHotCakesProductModel cakesModel;
  LzHotCakesProductWidget({Key key, this.cakesModel}) : super(key: key);

  @override
  _LzHotCakesProductWidgetState createState() => _LzHotCakesProductWidgetState();
}

class _LzHotCakesProductWidgetState extends State<LzHotCakesProductWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xFFF4F4F4),
      padding: EdgeInsets.fromLTRB(16, 16, 16, 0),
      child: GestureDetector(
        onTap: () {
          RouteUtil.goParameter(DetailsPage(id: widget.cakesModel.id));
        },
        child: Container(
          decoration: BoxDecoration(borderRadius: BorderRadius.circular(5.0), color: Colors.white),
          padding: EdgeInsets.fromLTRB(12, 14, 12, 12),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              //图片1
              Container(
                decoration: BoxDecoration(borderRadius: BorderRadius.circular(5.0), color: Colors.white),
                child: FadeInImage.assetNetwork(
                  image: widget.cakesModel.imgUrl,
                  width: 55,
                  height: 55,
                  placeholder: 'images/picture_loading.png',
                  fit: BoxFit.fill,
                ),
              ),
              //详情2
              Expanded(
                child: Container(
                  height: 60,
                  padding: EdgeInsets.only(left: 10),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      //名字
                      Container(
                        child: Text(
                          widget.cakesModel.name,
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                            color: Color(0xFF3A3B3E),
                            fontSize: Dimens.FONT_SIZE_14,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                      Container(
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                Container(
                                  child: Text(
                                    "¥" + widget.cakesModel.outPrice,
                                    style: TextStyle(
                                      color: Color(0xFFF5544B),
                                      fontSize: Dimens.FONT_SIZE_14,
                                      fontWeight: FontWeight.bold,
                                    ),
                                  ),
                                ),
                                Container(
                                  padding: EdgeInsets.only(left: 10),
                                  child: Text(
                                    "已售:${widget.cakesModel.hadShopCt}件",
                                    style: TextStyle(
                                      color: Color(0xFFA8A8A8),
                                      fontSize: Dimens.FONT_SIZE_12,
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Container(
                              padding: EdgeInsets.only(left: 10),
                              child: Text(
                                widget.cakesModel.giftRemark,
                                style: TextStyle(
                                  color: Color(0xFFA8A8A8),
                                  fontSize: Dimens.FONT_SIZE_12,
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
